#include "stdafx.h"

OilModel::OilModel(sim *_main, const QString &_name)
	: main(_main), name(_name)
{
	init_model();
}


OilModel::~OilModel(){}

void OilModel::init_model(){
	//0 - combobox/boolean
	//1 - spinbox
	//2 - textbox
	//3 - label
	model = new PropertiesModel(this);
	model->addItem("NAME", name, "", 2, 0,"test1");
	model->addItem("DENSITY", 0, "kg/m3", 1, 0,"test2");
	model->addItem("VISCOSITY", "", "-", 3, 0,"test3");
	model->addItem("DINAMIC", 0, "CP", 1, 0,"test4", "", true);
	model->addItem("KINEMATIC", 0, "-", 1, 0,"test5", "", true);
	model->addItem("SOUND SPEED", 0, "km/h", 1, 0,"test6");
    model->addItem("SVPRESSURE", 0, "Pa", 1, 0,"saturated vapour pressure");


	connect(this, SIGNAL(setModelData(const int &, const int &, const QVariant &)), 
		model, SLOT(changeData(const int &, const int &, const QVariant &)));

	connect(model, SIGNAL(ItemChanged(const int &, const int &, const QVariant &)),
		this, SLOT(getModelData(const int &, const int &, const QVariant &)));

	connect(model, SIGNAL(update()), this, SLOT(updateProperties()));
}


/*
void OilModel::getModelData(const int &parent_row, const int &row, const QVariant &value){
	if (parent_row == -1 && row == 0){
		main->cmOilModel->setItemText(main->cmOilModel->currentIndex(), value.toString());
		return;
	}
}*/

void OilModel::updateProperties(){
	main->properties->setItemDelegate(new Delegate(main));
}
